<template>
<div class="">
  <Row>

    <Col span="12" class="title clearfix">受孕情况</Col>

  </Row>
  <div class="line"></div>
  <div class="MainBox">
    <Form :model="Ingravidation" label-position="left" :label-width="50">
      <Form-item label="是否验孕成功" class="clearfix">
        <Select v-model="Ingravidation.pregnancy" style="float:left">
		      	 <Option v-for="item in PregnantStatusList" :value="item.value" :key="item.value">{{ item.label }}</Option>
		   		 </Select>
        <!-- <Input v-model="Ingravidation.PregnantStatus"  style="display:none" /> -->
      </Form-item>
      <UploadHelperForKey label=" HCG 验血报告"  :showdata="Ingravidation['hcg']"  uploadkey="HCG" />
      <UploadHelperForKey label="国内跟踪报告(图)"  :showdata="Ingravidation['other']" uploadkey="pregnancy_other" />
      <Form-item label="国内跟踪报告(文)">
        <Input v-model="Ingravidation.pregnancy_remarks" type="textarea" :autosize="{minRows: 3,maxRows: 8}" placeholder="国内跟踪报告备注"></Input>
      </Form-item>
      <submit-button @submit="submit" @cancel="cancel"></submit-button>
    </Form>
  </div>
</div>
</template>
<script>
import UploadHelperForKey from '../components/UploadHelperForKey';
import Store from '../store'
import SubmitButton from "../components/SubmitButton"
import api from '../js/axios-module'

export default {
  data() {
    return {
      bodyType: '',
      Ingravidation: {
      },
      PregnantStatusList: [{
          value: 'Status-Yes',
          label: '是'
        },
        {
          value: 'Status-No',
          label: '否'
        },
        {
          value: 'Status-Wait',
          label: '待定'
        }
      ]
    }
  },
  created: function() {
    this.Ingravidation = Store.fetch(Store.INGRAVIDATION_KEY)
    api.getIngravidation().then(response=>{
      this.Ingravidation = response.data.data
    });
  },
  components: {
    SubmitButton,
    UploadHelperForKey,
  },
  methods: {
    submit: function() {
      const data = {
        'pregnancy': this.Ingravidation.pregnancy,
        'pregnancy_remarks': this.Ingravidation.pregnancy_remarks
      }
      api.editIngravidation(data).then(response=>{
        if(response.data.code == '200'){
          this.$Message.success('提交成功');
        }else{
          this.$Message.error('提交失败');
        }
      });
    },
    cancel: function() {
      console.log("cancel")
    },
  },
  watch: {
    Ingravidation: {
      handler: function(ingravidation) {
        // console.log(ingravidation)
      },
      deep: true
    }
  }
}
</script>
<style scoped>
</style>
